#include <stdio.h>

int main() {
	int a, b;
	int t = 1;
	scanf("%d %d", &a, &b);
	while (t > 0) {
		t = a % b;
		a = b;
		b = t;
	}
	printf("%d", a);

	return 0;
}